﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class WinZone : MonoBehaviour
{
    public GameObject passwordPanel;
    public InputField inputFiled;

    int playerLayer;

    private void Start()
    {
        playerLayer = LayerMask.NameToLayer("Player");
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.layer == playerLayer)
        {
            passwordPanel.SetActive(true);
        }
        
    }

    public void PasswordVerify()
    {
        if (inputFiled.text.Contains("047"))
        {
            passwordPanel.SetActive(false);
            GameManager.PlaerWon();
        }
        else
        {
            inputFiled.text = "";
            inputFiled.placeholder.GetComponent<Text>().text = "密码错误,请重新输入";
        }
    }

    public void ClosePanel()
    {
        passwordPanel.SetActive(false);
    }
}
